trigger ownerOnAccount on Account (before update,before insert) {

Set<Id> AccId = new Set<id>();
Set<Decimal> shortid= new Set<Decimal>();
List<Id> poOwId = New List<Id>();
for (Account a : Trigger.new){
     AccId.add(a.id);
     shortid.add(a.Shortuser__c);
    }
Map<id,Account> mapAccount = new map<id,Account>([Select OwnerId from Account where id in :AccId]);
System.debug('pomap' + mapAccount);
List<user> users = [Select id,Shortuser__c from user where Shortuser__c in : shortid];
System.debug('users' + users);
Map<id,user> mapoNid = new Map<id,user>([Select id,Shortuser__c from user where  id In : users]);
System.debug('map' + mapoNid);   
 for(user u : users){                
      for(Account a :Trigger.New){        
             if(a.Shortuser__c == u.Shortuser__c){
             a.OwnerId =  mapoNid.get(u.Id).Id; 
            System.debug('acccid'   +   a.OwnerId);             
       }
      }     
     }
   }